var login = document.querySelectorAll(".login-type");
var row_show = document.querySelectorAll(".row_show");
console.log(row_show);


// 手机登录切换

for (let i = 0; i < login.length; i++) {
    login[i].addEventListener("click", function () {
        for (let i = 0; i < login.length; i++) {
            login[i].classList.remove("sectioned")
        }
        this.classList.add("sectioned")

        login[i].setAttribute("index", i);
        let index = this.getAttribute("index");
        console.log(index)

        for (let k = 0; k < row_show.length; k++) {
            row_show[k].style.display = "none"
        }
        row_show[index].style.display = "block";
    })
}


// phone显示、隐藏

//获取号码前缀把号码赋值给它；
var num = document.querySelector(".num");
console.log(num)
//获取点击之后显示的ul；
var num_uls = document.querySelector(".num_uls");
//点击num 显示num_uls
//获取 uls 下的li
var lis = document.querySelectorAll(".num_uls li")
var span = document.querySelectorAll(".num_uls li span")


num.addEventListener("click", function (e) {
    num_uls.classList.add("active");

})

lis.forEach(function (item, index) {
    item.onclick = function () {

        for (let i = 0; i < span.length; i++) {

            num.textContent = span[index].textContent;

        }
        num_uls.classList.remove("active");
    }
})


// 验证码
//设置默认的空字符串
var code = "";
var codeDiv = document.getElementById("code");

var newCodeInput = document.getElementById("newCode");

var validate = document.getElementById("validate");

var inner_span = document.getElementsByClassName("inner_span")[0];
console.log(inner_span)

creatCode()

//1、获取min到max之间的整数（1-100）
function random(max, min) {
    return Math.floor(Math.random() * (max - min) + min);

}

function creatCode() {
    var codeLength = 4;
    var randomCode = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
    for (var i = 0; i < codeLength; i++) {
        var index = random(0, 36);
        code += randomCode[index];
    }
    codeDiv.innerHTML = code;
}

//验证按钮效验
validate.onclick = function () {
    var newCode = newCodeInput.value.toUpperCase();
    if (newCode === code) {
        //验证成功

        inner_span.innerHTML = "验证成功";
        inner_span.style.color = "#52ccba";
    }
    else {
        //验证失败
        inner_span.innerHTML = "验证码错误";
        inner_span.style.color = "red";

        //输入框清空
        newCodeInput.value = ''

    }
}


// 更多方式登录

var more = document.querySelector(".more");
var tt_uls = document.querySelector(".tt-uls");
//获取图标
var more_bottom = document.querySelector(".more_bottom")
console.log(more, tt_uls)

more.addEventListener("click", function (e) {


    if (tt_uls.className.indexOf("ul_show") > -1) {
        tt_uls.classList.remove("ul_show");
        more_bottom.classList.remove("rotate")
    } else {
        tt_uls.classList.add("ul_show");
        more_bottom.classList.add("rotate")
    }




})